package myschool.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */

public class Page<T> implements Serializable {
    public static final int PAGESIZE=10;
    private int code=0;
    //本页数据
    private List<T> data = new ArrayList<>(0);
    private int pageNo = 1;///
    private int count;//总数
    private int pageTotal;//总页数
    private int pageSize = PAGESIZE;//

    public Page(){

    }
    public Page(List<T> data, int total, int pageSize) {
        this.data = data;
//        this.count = count;
        this.setCount(total);
        this.pageSize = pageSize;
    }
    public Page(List<T> data, int pageNo, int total, int pageSize) {
        this.data = data;
        this.pageNo = pageNo;
//        this.count = count;
        this.pageSize = pageSize;
        this.setCount(total);

    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
        this.pageTotal = this.count / this.pageSize + (this.count % this.pageSize == 0 ? 0 : 1);
    }

    public int getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(int pageTotal) {
        this.pageTotal = pageTotal;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
